package com.wtc.homework8;


public class Homework13 {
    public static void main(String[] args) {
        Person[] person = new Person[4];
        person[0] = new Student("马可", '男', 21, 2101303069);
        person[1] = new Student("make", '男', 18, 210135669);
        person[2] = new Teacher("王老师", '男', 25, 15);
        person[3] = new Teacher("李老师", '女', 28, 10);

        for (int i = 0; i < person.length - 1; i++) {
            Person[] temp = new Person[4];
            for (int j = 0; j < person.length - 1 - i; j++) {
                if (person[j].getAge() < person[j + 1].getAge()) {
                    temp[0] = person[j + 1];
                    person[j + 1] = person[j];
                    person[j] = temp[0];
                }
            }
            System.out.println(person[i].toString());
        }
        Student student = new Student("马可", '男', 21, 2101303069);
        put(student);
    }
    public static void put(Person person) {
        if (person instanceof Student) {
            ((Student)person).study();
        }
        if (person instanceof Teacher) {
            ((Teacher)person).teach();
        }
    }
}
